<%@ page import="java.io.* , java.util.*, java.sql.*, com.myapp.struts.dao.*,com.myapp.struts.actionform.*,com.myapp.struts.beans.*"%>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Item Master</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <link href="../../../../css/cms.css" rel="stylesheet" type="text/css">
        <script language="javascript" type="text/javascript">
            function Validate()
            {
                var inde=document.Alloc2.loca.selectedIndex;
                if(inde==0)
                {
                    alert("Please Make a Selection From Location.......");
                    document.Alloc2.loca.focus();
                    return false;
                }else if(document.getElementById("rdate1").value=="" || parseInt(document.getElementById("rdate1").value)<=0 || parseInt(document.getElementById("rdate1").value)>=32 || parseInt(document.getElementById("rdate1").value)!= document.getElementById("rdate1").value)
                {
                    alert("Enter Day Between (1-31)");
                    document.getElementById("rdate1").focus();
                    return false;
                }
                else if(document.getElementById("rmonth1").value=="" || parseInt(document.getElementById("rmonth1").value)<=0 || parseInt(document.getElementById("rmonth1").value)>=13 || parseInt(document.getElementById("rmonth1").value)!= document.getElementById("rmonth1").value)
                {
                    alert("Enter month Between (1-12) 1");
                    document.getElementById("rmonth1").focus();
                    return false;
                }
                else if(document.getElementById("ryear1").value =="" || parseInt(document.getElementById("ryear1").value)<=1939 || parseInt(document.getElementById("ryear1").value)>=2222|| parseInt(document.getElementById("ryear1").value)!= document.getElementById("ryear1").value)
                {
                    alert("Enter year between 1940-90");
                    document.getElementById("ryear1").focus();
                    return false;
                }

            }
        </script>
        <script type="text/javascript">

            var monthtext=[1,2,3,4,5,6,7,8,9,10,11,12];

            function populatedropdown(dayfield, monthfield, yearfield){
                var today=new Date()
                var dayfield=document.getElementById(dayfield)
                var monthfield=document.getElementById(monthfield)
                var yearfield=document.getElementById(yearfield)
                for (var i=0; i<31; i++)
                    dayfield.options[i]=new Option(i, i+1)
                dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
                for (var m=0; m<12; m++)
                    monthfield.options[m]=new Option(monthtext[m], monthtext[m])
                monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
                var thisyear=today.getFullYear()
                for (var y=0; y<20; y++){
                    yearfield.options[y]=new Option(thisyear, thisyear)
                    thisyear+=1
                }
                yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
            }

        </script>
    </head>
    <body>
        <form action="../../../../AllocateItems" method="post" name="Alloc2" onSubmit="return Validate();">
            <p>&nbsp;</p>
            <table width="412" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr >
                    <th height="30" colspan="3" align="center" valign="middle" ><span class="style14">Issues</span></th>
                </tr>
                <tr >
                    <td colspan="2" ><span class="style12">Site Code</span></td>
                    <%
            String[] items = request.getParameterValues("temp");
                    %>
                    <td width='168' ><select name="siteCode" id="siteCode" onChange="javascript:getLocationDetails()">
                            <option> </option>
                            <%
                LocationMasterDao imdao = new LocationMasterDao();
                Vector gp = imdao.getLocations();
                if (gp != null) {
                    Iterator itg = gp.iterator();
                    while (itg.hasNext()) {
                        LocationMasterFormBean gb = (LocationMasterFormBean) itg.next();
                        String pname = gb.getLocationCode();
                            %>
                            <option value="<%=pname%>"><%=pname%></option>
                            <%}

                }%>
                        </select>
                <tr>
                    <th>Item</th>
                    <th>Present Qty</th>
                    <th>Allocating Qty</th>
                </tr>
                <%
        session.setAttribute("items", items);

        String nuu = "";
                        AllocationDao sdao=new AllocationDao();
                
        for (int j = 0; j < items.length; j++) {
            nuu = items[j].replaceAll("\"", "&quot;");
            nuu = items[j].replaceAll("&", "&amp;");
            nuu = items[j].replaceAll("\'", "\\" + "\''");
            double gp1 = sdao.getItemQty(nuu);
                %>

                <tr>
                    <td width="142"><%=nuu%>  Qty</td>
                    <td width="102"><%=gp1%></td>
                    <td ><input type='text' name='qty'></td>
                        <%}

                        %>
                </tr>
                <tr >
                    <td height="24" colspan="2" align="left" valign="middle" ><span class="style12">Date</span></td>
                    <td width="168" height="24" align="left" valign="middle" ><strong>
                            <select id="daydropdown" name="daydropdown">
                            </select>
                        </strong>                  -
                        <strong>
                            <select id="monthdropdown" name="monthdropdown">
                            </select>
                            -
                            <select id="yeardropdown" name="yeardropdown">
                            </select>

                            <script type="text/javascript">

                                //populatedropdown(id_of_day_select, id_of_month_select, id_of_year_select)
                                window.onload=function(){
                                    populatedropdown("daydropdown", "monthdropdown", "yeardropdown")
                                }
                            </script>
                        </strong></td>
                </tr>
                <tr>
                    <td height="24" colspan="3" align="center" valign="middle" >
                        <input name="Submit" type="submit" class="subHeader " value="Submit" /></td>
                </tr>
            </table>
        </form></body>
</html>
